package com.async;


import java.util.concurrent.Future;

/**
 * main函数里面还是会依次执行，异步无效。
 */
public class TestAsync {

    public static void main(String[] args) throws InterruptedException {

        long start = System.currentTimeMillis();



        Future<String> task1 = AsyncTask.doTaskOne();
        Future<String> task2 = AsyncTask.doTaskTwo();
        Future<String> task3 = AsyncTask.doTaskThree();

        while (true){
            if(task1.isDone() && task2.isDone() && task3.isDone()){
                break;
            }
            Thread.sleep(1000);
        }

        long end = System.currentTimeMillis();
        System.out.println("任务全部完成，总耗时：" + (end - start) + "毫秒");

    }
}
